<template>
    <div>
        <div class="content">
            <div class="return" @click="close">
                <img class="img1" src="../../assets/img/return.png" alt="" />
                <p class="return-p">返回</p>
            </div>
                <div class="qrcode-title">{{ title }}</div>
                <div style="
                margin:.3rem 0;
              display: flex;
              align-items: center;
              justify-content: space-around;
            ">
                    <div  class="qrcode"  id="qrcode" ref="qrCodeUrl"></div>
                </div>
                <div class="qrcode-titles">扫码领券</div>
            </div>
    </div>
</template>
    
<script>
import QRCode from 'qrcodejs2'
export default {
    name: 'qrcode',
    data() {
        return {
            title:'',
            text:'',
            qrcode:null,
        };
    },
    mounted() {

    },
    activated() {
        console.log(this.$route.query);

        if(this.$route.query.name){
            this.title = this.$route.query.name+'店铺'+ this.$route.query.money+ "元代金券"
        }
        if(this.$route.query.qrcode){
            this.text = 'https://www.tunquanquan.com/CloudPhoneMain/?qrcode='+this.$route.query.qrcode+'&name='+this.$route.query.name+ '&money='+this.$route.query.money
            this.creatQrCode(); // 生成新的二维码
        }
    },
    methods: {
        creatQrCode() {
            document.getElementById("qrcode").innerHTML = "";
            this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
                text: this.text, // 需要转换为二维码的内容
                width: 200,
                height: 200,
                colorDark: '#000000',
                colorLight: '#ffffff',
                correctLevel: QRCode.CorrectLevel.H
            })
        },
        close() {
            window.history.go(-1);
        },
    },
};
</script>
    
<style scoped>
.content {
    padding-bottom: 30px;
    overflow: hidden;
    width: 100%;
    min-height: 100vh;
    background: #fff;
}

.card1 {
    overflow: hidden;
    margin: 0.3rem auto 0;
    padding: 0.25rem 0.5rem;
    width: 75%;
    background: #fff;
    border-radius: 0.375rem;
}

.card1-title {
    margin-top: 0.2rem;
    font-size: 0.4125rem;
    font-weight: 600;
    color: #000;
}

.card1-text {
    margin: 0.25rem 0 0 0.2rem;
    font-size: 0.3125rem;
    font-weight: 600;
    color: #000;
}

.card1-text1 {
    margin: 0.25rem 0 0 0.2rem;
    font-size: 0.3125rem;
    font-weight: 600;
    color: #000;
    text-align: center;
}

.img1 {
    display: inline-block;
    width: 27px;
    height: 48px;
    vertical-align: middle;
}

.return {
    margin: 20px 0 0 30px;
    font-size: 40px;
}

.return-p {
    margin-left: 20px;
    display: inline-block;
    vertical-align: middle;
}

.norecords {
    margin-top: 2rem;
    color: #ffbe4c;
    font-size: .5rem;
    text-align: center;
}

.addStore {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1rem;
    font-size: .4rem;
    text-align: center;
    color: #AD3516;
    background: linear-gradient(180deg, #FFE9C6, #FFD584);
    box-shadow: 0px 3px 8px 0px rgba(150, 51, 20, 0.42);
    line-height: 1rem;
    border-radius: .5rem;
}

.confirmBtn {
    margin-top: .2rem;
    margin-left: .2rem;
    width: 2rem;
    height: .8rem;
    background: #FFD584;
    box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(0, 0, 0, 0.25);
    border-radius: 0.6rem;
    opacity: 1;
    color: #000;
    border: none;
    font-size: 0.3rem;
}

.cancelBtn {
    margin-top: .2rem;
    margin-left: .2rem;
    width: 2rem;
    height: .8rem;
    background: #FFD584;
    box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(0, 0, 0, 0.25);
    border-radius: 0.6rem;
    opacity: 1;
    color: #000;
    border: none;
    font-size: 0.3rem;
}

.tipsContent {
    width: 100%;
    margin: 0.5rem 0 .3rem;
    display: inline-block;
    font-size: 0.4rem;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #111111;
}

.input {
    display: inline-block;
    margin-left: 0.1rem;
    margin-top: 0.4rem;
    width: 60%;
    background: white;
    border: none;
    padding: 0.1875rem 0.25rem;
    border-radius: 0.25rem;
    /*  border-inline: 2px solid transparent; */
}

.addAssistant {
    width: 100%;
    text-align: center;
    font-size: .4rem;
}

.line {
    margin: 0 auto;
    width: 90%;
    height: 2px;
    background-color: #ccc;
}

.editBtn {
    margin-left: .2rem;
    padding: 0 .4rem;
    display: inline-block;
    background-color: #FFD584;
    border-radius: .4rem;
    height: .5rem;
    text-align: center;
    line-height: .5rem;
}

.editBtns {
    padding: 0 .3rem;
    display: inline-block;
    background-color: red;
    border-radius: .4rem;
    height: .5rem;
    text-align: center;
    line-height: .5rem;
    color: #fff;
}

.aidee-selete {
    margin: 0.7rem 0 0 0.55rem;
    font-size: 0.35rem;
    font-family: PingFang;
    font-weight: 500;
    color: #7796cb;
}

.aidee-selete-span {
    color: red;
}

.aside-input1 {
    box-sizing: border-box;
    padding-left: 0.525rem;
    width: 80%;
    height: 1.05rem;
    color: #7796cb;
    font-weight: 500;
    font-size: 0.35rem;
    font-family: PingFang;
    line-height: 1.05rem;
    border-radius: .5rem;
    border: 1px solid #ccc;
}

::v-deep .van-tabs__nav {
    background-color: #e1f7fc;
}

::v-deep .van-tab {
    font-size: 0.377rem;
}

.tab {
    margin-top: .2rem;
}
.qrcode-title {
    margin: 1.5rem 0 .8rem;
    width: 100%;
    text-align: center;
    font-size: .4rem;
    font-weight: 600;
}
.qrcode-titles {
    margin: .8rem 0;
    width: 100%;
    text-align: center;
    font-size: .4rem;
     font-weight: 600;
}
</style>